package com.hzspace.thymeleaf.contoller;

import com.hzspace.thymeleaf.bean.Book;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: LiuHao
 * @Descirption:
 * @Date: 2020/2/27_16:12
 */
@Controller
public class BookController {

    @GetMapping("/book")
    public String book(Model model) {
        List books = new ArrayList();
        for (int i = 0; i < 10; i++) {
            Book book = new Book();
            book.setId((long) i);
            book.setName("三国演义:" + i);
            book.setAuthor("罗贯中:" + i);
            book.setPrice(30.0);
            books.add(book);
        }
        model.addAttribute("books", books);
        return "book";
    }
}
